package com.highveldsky.appengine.xmppplay;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.xmpp.JID;
import com.google.appengine.api.xmpp.XMPPService;
import com.google.appengine.api.xmpp.XMPPServiceFactory;

@SuppressWarnings("serial")
public class SendInvitation extends HttpServlet {

	private static final Logger log = Logger.getLogger(SendInvitation.class.getName());
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		log.info("Sending invitaion");
		
		JID jid = new JID(req.getParameter("recipient"));
		XMPPService xmpp = XMPPServiceFactory.getXMPPService();
		xmpp.sendInvitation(jid);

		resp.setContentType("text/plain");
		resp.getWriter().println("Invitation sent");
		
	}

}
